﻿Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.SearchForm = function (config) {
    Ext.apply(this, config);
    this.items = [{
        layout: 'column',
        border: false,
        labelSeparator: '：',
        items: [{
            columnWidth: 1,
            layout: 'form',
            border: false,
            items: [new Ext.form.TextField({
                fieldLabel: '名称',
                name: 'Name',
                width: 200
            })]
        }, {
            columnWidth: 1,
            layout: 'form',
            border: false,
            items: [new Ext.form.TextField({
                fieldLabel: '地址',
                name: 'Address',
                width: 200
            })]
        }]
    }];
    FantastPlatform.UI.SearchForm.superclass.constructor.call(this, {
        bodyStyle: 'padding-top:25px',
        collapsible: true,
        labelAlign: 'right',
        buttonAlign: 'center',
        autoScroll: false
    });
};
Ext.extend(FantastPlatform.UI.SearchForm, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.SearchForm.superclass.onRender.call(this, ct, position);
    },
    submitSearchFormJson: function (form, grid, sender, data) {
        if (form.form.isValid()) {

            var dataStr = Ext.util.JSON.encode(form.form.getValues());
            grid.store.baseParams = {
                data: dataStr
            }
            grid.store.removeAll();
            grid.store.proxy.conn = { method: 'post', url: form.url };
            grid.store.load({ params: { start: 0, limit: grid.paperBar.getPageNumber(), dir: '', sort: '', data: dataStr} });
            if (sender)
                sender.close();

        }
    }

});